package com.longteng.diamond.dao;


import com.longteng.diamond.domain.ProjectShareNode;
import org.apache.ibatis.annotations.*;


import java.util.List;

/**
 * Created by Administrator
 * DATE : 2018/7/23
 * TIME : 22:18
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:taki@qq.com">Administrator</a>
 */
@Mapper
public interface ProjectHostMapper  extends BaseMapper{
    /**
     * 查询host
     * @param projectShareNode
     * @return
     */
    @Override
    List<ProjectShareNode> getProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 查询host
     * @param projectShareNode
     * @return
     */
    @Select("select * from host where yn =1 and projectId=#{projectId} and domain=#{domain}")
    ProjectShareNode getHostByDomain(ProjectShareNode projectShareNode);
    /**
     * 查询host
     * @param projectId
     * @return
     */
    @Select("select * from host where yn =1 and projectId=#{projectId}")
    List<ProjectShareNode> getHostByProjectId(Integer projectId);
    /**
     * 查询所有host
     * @param projectShareNode
     * @return
     */
    @Override
    long queryAllRow(ProjectShareNode projectShareNode);
    /**
     * 通过id查找
     * @param id
     * @return
     */
    @Override
    @Select("select * from host where id=#{id}")
    ProjectShareNode findProjectShareNodeById(Integer id);
    /**
     * 新增host
     * @param projectShareNode
     * @return
     */
    @Insert("insert into host(ip,domain,projectId,createTime,updateTime,yn) " +
            "values(#{ip},#{domain},#{projectId},now(),now(),1)")
    void addProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 修改host
     * @param projectShareNode
     * @return
     */
    @Update("update host set ip =#{ip},domain =#{domain},updateTime=now() where id =#{id}")
    void updateProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 删除host
     * @param id
     * @return
     */
    @Delete("update host set yn =0,updateTime=now() where id =#{id}")
    void deleteProjectShareNode(@Param("id") Integer id);
}
